
#ifndef  BREAKPOINTSERVICE_H
#define  BREAKPOINTSERVICE_H
#include <string>
#include <ostream>


class IBreakPoint;
class IBreakPointStateEvent;
class BreakPointService {
public:
    BreakPointService();
    ~BreakPointService();

    int start();
    int stop();

    int connected();
    int disconnected();

    int timeout();

    int receivedLoginResp(const char * msg);
    int receivedNormalResp(const char * msg);
    int receivedBreakPointResp(const char * msg);

    int sendMessage(const char * msg);

    //for test
    const IBreakPointStateEvent & getState() const;
    void setState(IBreakPointStateEvent * state);

private:
    int loadFromFile();
    int saveToFile();

    int login();
    int logDisconnected();

    int queryBreakPoint();

    int handleLoginResp(const char * msg);
    int handleNormalResp(const char * msg);
    int handleBreakPointResp(const char * msg);
    int sendMessageAction(const char * msg);

private:
    friend class BreakPointEndState;
    friend class BreakPointInitedState;
    friend class BreakPointConnectedState;
    friend class BreakPointLoginedState;
    friend class BreakPointDisconnectedState;
private: 
    IBreakPointStateEvent * state;
    IBreakPoint * breakPoint;
};

#endif   /* BREAKPOINTSERVICE_H */
